package be.kuleuven.cs.mop.domain.exceptions;


import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import be.kuleuven.cs.mop.domain.model.Task;
import be.kuleuven.cs.mop.domain.model.TaskStatus;
import be.kuleuven.cs.mop.domain.model.impl.TaskImpl;



public class BusinessRuleTwoViolationExceptionDependantTasks extends BusinessRuleViolationException {
	private static final long serialVersionUID = 1L;
	
	public static final String DEFAULT_MESSAGE = "When a task depends on a task with a Failed status, it should have a Failed status itself. When a Task depends on a task with an Unfinised status, it should have the status Unavailable or Failed.";
	
	private final HashMap<TaskImpl, TaskStatus> suggestions;
	
	/**
	 * Business Rule Two Violation Exception occuring when a task changes its state to failed while one of the tasks that depend on this task is not failed
	 *  
	 * @param suggestions - A hashmap containing suggested states for the tasks that violate business rule 2
	 */
	public BusinessRuleTwoViolationExceptionDependantTasks(final String msg, HashMap<TaskImpl, TaskStatus> suggestions) {
		super(msg);
		if (suggestions == null)
			throw new NullPointerException("suggestions == NULL");
		this.suggestions	= suggestions;
	}
	
	/**
	 * @see #BusinessRuleTwoViolationExceptionDependantTasks
	 */
	public BusinessRuleTwoViolationExceptionDependantTasks(HashMap<TaskImpl, TaskStatus> suggestions) {
		this(DEFAULT_MESSAGE, suggestions);
	}
	
	/**
	 * Returns a hashmap containing suggested states for the tasks that violate business rule 2
	 */
	public Map<? extends Task, TaskStatus> getSuggestions() {
		return Collections.unmodifiableMap(suggestions);
	}
	
	
	
}